package com.ruoyi.business.service.impl;

import com.ruoyi.business.domain.WmsFactory;
import com.ruoyi.business.mapper.WmsFactoryMapper;
import com.ruoyi.business.service.IWmsFactoryService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 工厂管理Service业务层处理
 * 
 * @author sz
 * @date 2024-01-03
 */
@Service
public class WmsFactoryServiceImpl implements IWmsFactoryService
{
    @Autowired
    private WmsFactoryMapper wmsFactoryMapper;

    /**
     * 查询工厂管理
     * 
     * @param id 工厂管理ID
     * @return 工厂管理
     */
    @Override
    public WmsFactory selectWmsFactoryById(Long id)
    {
        return wmsFactoryMapper.selectWmsFactoryById(id);
    }

    /**
     * 查询工厂管理列表
     * 
     * @param wmsFactory 工厂管理
     * @return 工厂管理
     */
    @Override
    public List<WmsFactory> selectWmsFactoryList(WmsFactory wmsFactory)
    {
        return wmsFactoryMapper.selectWmsFactoryList(wmsFactory);
    }

    /**
     * 新增工厂管理
     * 
     * @param wmsFactory 工厂管理
     * @return 结果
     */
    @Override
    public int insertWmsFactory(WmsFactory wmsFactory)
    {
        wmsFactory.setCreateTime(DateUtils.getNowDate());
        return wmsFactoryMapper.insertWmsFactory(wmsFactory);
    }

    /**
     * 修改工厂管理
     * 
     * @param wmsFactory 工厂管理
     * @return 结果
     */
    @Override
    public int updateWmsFactory(WmsFactory wmsFactory)
    {
        wmsFactory.setUpdateTime(DateUtils.getNowDate());
        return wmsFactoryMapper.updateWmsFactory(wmsFactory);
    }

    /**
     * 删除工厂管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWmsFactoryByIds(String ids)
    {
        return wmsFactoryMapper.deleteWmsFactoryByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除工厂管理信息
     * 
     * @param id 工厂管理ID
     * @return 结果
     */
    @Override
    public int deleteWmsFactoryById(Long id)
    {
        return wmsFactoryMapper.deleteWmsFactoryById(id);
    }

    @Override
    public WmsFactory selectWmsFactoryBySn(String sn) {
        WmsFactory factory = new WmsFactory();
        factory.setSn(sn);
        List<WmsFactory> list = wmsFactoryMapper.selectWmsFactoryList(factory);
        if(list.isEmpty()){
            return null;
        }else{
            return list.get(0);
        }
    }
}
